<template>
  <div>
    <a-card :bordered="false">
      <f-table ref="table" rowKey="materialPackage100Id" :scroll="{x:2310}" :columns="columns" :exportBtn="false"
               :multiple="false" :operator="operator" :params="queryParam" :api="api.bmp"
               handler="materialPackagePageListHandler">
      </f-table>
    </a-card>
  </div>
</template>
<script>
  import api from './js/api'

  export default {
    name: 'TableList',
    props: {
      detailsParams: {}
    },
    components: {},
    data() {
      let me = this
      //操作按钮
      let operator = []
      return {
        api: Object.assign(api, this.api),
        //列表初始化查询参数
        queryParam: this.detailsParams,
        // 表头
        columns: [
          {
            title: '序号',
            width: 80,
            align: 'center',
            customRender: (text, record, index) => index + 1
          },
          {
            title: '分包Id',
            width: 180,
            align: 'center',
            dataIndex: 'materialPackage100Id'
          },
          {
            title: '项目代码',
            width: 150,
            align: 'center',
            dataIndex: 'projectCode'
          },
          {
            title: '项目名称',
            width: 150,
            align: 'center',
            dataIndex: 'projectName'
          },
          {
            title: '服务代码',
            width: 150,
            align: 'center',
            dataIndex: 'serviceCode'
          },
          {
            title: '服务WBS代码',
            width: 150,
            align: 'center',
            dataIndex: 'serviceWbsCode'
          },
          {
            title: '项目（名称）',
            width: 150,
            align: 'center',
            dataIndex: 'materiaSpecs'
          },
          {
            title: '科目名称',
            width: 150,
            align: 'center',
            dataIndex: 'subjectName'
          },
          {
            title: '层级号',
            width: 150,
            align: 'center',
            dataIndex: 'levelNo'
          },
          {
            title: '分承包发包项目描述',
            width: 200,
            align: 'center',
            dataIndex: 'packageDesc'
          },
          {
            title: '区域',
            width: 150,
            align: 'center',
            dataIndex: 'materialArea'
          },
          {
            title: '系统',
            width: 150,
            align: 'center',
            dataIndex: 'materialUse'
          },
          {
            title: '标前工程量',
            width: 150,
            align: 'center',
            dataIndex: 'beforeMarkQuantity'
          },
          {
            title: '100预算成本工程量',
            width: 200,
            align: 'center',
            dataIndex: 'costQuantity100'
          }
        ],
        operator: operator
      }
    },
    created() {
      this.getBusProjectAllSupplierInfo()
    },
    methods: {
      getBusProjectAllSupplierInfo() {
        this.http.get(this, {
          url: this.api.bmp.getBusProjectAllSupplier,
          data: this.detailsParams,
          success(me, data) {
            console.log(data)
            for (let i in data) {
              let info = data[i]
              me.columns.push({
                title:info.supplierName + '合同量',
                width: 150,
                align: 'center',
                dataIndex: 'supplierNum' + info.index
              })
            }
          }
        })
      }
    }
  }
</script>
